﻿using VirtualTournaments.DataAccess.EntityManagers;
using VirtualTournaments.DataAccess.SqlServer.DataMappers;

namespace VirtualTournaments.DataAccess.SqlServer.EntityManagers
{
	internal sealed class UsersManager : IUsersManager
	{
		#region Singleton implementation

		private static UsersManager _instance = null;
		private static readonly object _instanceLocker = new object();

		private UsersManager()
		{
		}

		public static UsersManager Instance
		{
			get
			{
				if (_instance == null)
				{
					lock (_instanceLocker)
					{
						if (_instance == null)
						{
							_instance = new UsersManager();
						}
					}
				}
				return _instance;
			}
		}

		#endregion

		#region IUsersManager Members

		public Business.Users.User GetByUserName(string userName)
		{
			return UsersDataMapper.Instance.GetOneAsBusinessObject(user => user.UserName.ToLower() == userName.ToLower());
		}

		#endregion

		#region IEntityManager<IUser> Members

		public System.Collections.Generic.IEnumerable<Business.Users.User> GetAll()
		{
			throw new System.NotImplementedException();
		}

		public void Save(Business.Users.User entity)
		{
			throw new System.NotImplementedException();
		}

		public void Delete(Business.Users.User entity)
		{
			throw new System.NotImplementedException();
		}

		#endregion
	}
}
